package weiyunsuan;

import java.util.Random;
import java.util.Scanner;

public class _02找重复 {
    public static void main(String[] args) {
        /**
         * 1-1000的数组内有一个数重复，找出这个数
         */
        int N = 1001;
        int[] a = new int[N];
        Scanner sc = new Scanner(System.in);
        for (int i = 0; i < a.length - 1 ; i++ ){
            a[i] = i+1;
        }
        //最后一位数随机生成
        a[a.length - 1] =  new Random().nextInt(N-1)+1;

        for (int i = 0 ; i < a.length ; i++){
            System.out.print(a[i] + " ");
        }
        System.out.println();
        for (int i = 0 ; i < a.length ; i++){
            for (int j = i+1; j < a.length; j++){
                if (a[i] == a[j]){
                    System.out.println(a[i]);
                    break;
                }
            }
        }
    }
}
